import { RoleGuard } from '@/guards/role.guard'
import { applyDecorators, UseGuards, SetMetadata } from '@nestjs/common'
import { AuthGuard } from '@nestjs/passport'
import { Role } from '@prisma/client'

/**
 * 角色判断装饰器
 * @param {Role[]} roles
 * @returns
 */
export function LvAuth(...roles: Role[]) {
  return applyDecorators(SetMetadata('roles', roles), UseGuards(AuthGuard('jwt'), RoleGuard))
}
